package com.tac.controller;

import com.tac.common.result.Result;
import com.tac.pojo.User;
import com.tac.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/user")
@Api(tags = "用户接口")
public class UserController {

    @Autowired
    private UserService userService;

    @Value("${img.path}")
    private String url;
    //获取验证码
    @ApiOperation("获取验证码")
    @GetMapping("/getCode")
    public Result getCode(String username){
        return userService.getCode(username);
    }
    //登录
    @ApiOperation("登录")
    @PostMapping("/login/{code}")
    public Result login(@RequestBody User user, @PathVariable String code){
        return userService.login(user,code);
    }
    //注册
    @ApiOperation("注册")
    @PostMapping("/savaUser")
    public Result savaUser(@RequestBody User user){
        return userService.savaUser(user);
    }
    //更新头像
    @ApiOperation("更新头像")
    @PutMapping("/updateHead")
    public Result updateHead(String head){
        return userService.updateHead(head);
    }


}
